<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class RMStatisticsController extends Controller {
    /**
     * 导出Excel
     */
    public  function indexCount(){
        //获取本年度所有通过的、拒绝的订单
        $time=time();
        $year= date("Y",$time);
        $month= date("m",$time);
        $yearBegin=strtotime($year.'-01-01 00:00:00');
        $yearEnd=time();
        $orderOperation=M('order_operation');
        $whereOperation="(status=2 or status=-1) and create_time>=".$yearBegin;
        $orderOperationData=$orderOperation->field('orderid,status,create_time')->where($whereOperation)->select();
        //当月起始时间
        $monthBegin=strtotime($year.'-'.$month.'-01 00:00:00');
        $monthEnd=$time;
        //上月起始时间
        if($month==1){
            $lastMonthBegin=strtotime(($year-1).'-12-01 00:00:00');
            $lastMonthEnd=strtotime(($year-1).'-12-31 23:59:59');
        }else{
            $lastMonthBegin=strtotime($year.'-'.($month-1).'-01 00:00:00');
            $month_days=date('t', strtotime($year.'-'.($month-1).'-01'));
            $lastMonthEnd=strtotime($year.'-'.($month-1).'-'.$month_days.' 23:59:59');
        }
        //当前季度
        if($month<=3){
            $quarterBegin=strtotime($year.'-01-01 00:00:00');
            $quarterEnd=$time;
        }elseif($month>=4 && $month<=6){
            $quarterBegin=strtotime($year.'-04-01 00:00:00');
            $quarterEnd=$time;
        }elseif($month>=7 && $month<=9){
            $quarterBegin=strtotime($year.'-07-01 00:00:00');
            $quarterEnd=$time;
        }else{
            $quarterBegin=strtotime($year.'-10-01 00:00:00');
            $quarterEnd=$time;
        }
        $data=[];
        $data['month']['orderCount']=0;
        $data['month']['passOrderCount']=0;
        $data['lastMonth']['orderCount']=0;
        $data['lastMonth']['passOrderCount']=0;
        $data['quarter']['orderCount']=0;
        $data['quarter']['passOrderCount']=0;
        $data['year']['orderCount']=0;
        $data['year']['passOrderCount']=0;

        foreach($orderOperationData as $val){
            //当月订单
            if($val['create_time']<=$monthEnd && $val['create_time']>=$monthBegin){
                $data['month']['orderCount']+=1;
                if($val['status']==2){
                    $data['month']['passOrderCount']+=1;
                }
            }
             //上月订单
            if($val['create_time']<=$lastMonthEnd && $val['create_time']>=$lastMonthBegin){
                $data['lastMonth']['orderCount']+=1;
                if($val['status']==2){
                    $data['lastMonth']['passOrderCount']+=1;
                }
            }
             //当前季度订单
            if($val['create_time']<=$quarterEnd && $val['create_time']>=$quarterBegin){
                $data['quarter']['orderCount']+=1;
                if($val['status']==2){
                    $data['quarter']['passOrderCount']+=1;
                }
            }
            //当前年度订单
            if($val['create_time']<=$yearEnd && $val['create_time']>=$yearBegin){
                $data['year']['orderCount']+=1;
                if($val['status']==2){
                    $data['year']['passOrderCount']+=1;
                }
            }
        }

        //获取本年度所有需要还款的订单
        $orderMonthPay=M('order_month_pay');
        $whereMonthPay="pay_time>=".$yearBegin." and pay_time<=".$yearEnd;
        $orderMonthPayData=$orderMonthPay->field('orderid,overdue_status,pay_time')->where($whereMonthPay)->select();
        $data['month']['payOrderCount']=0;
        $data['month']['overOrderCount']=0;
        $data['lastMonth']['payOrderCount']=0;
        $data['lastMonth']['overOrderCount']=0;
        $data['quarter']['payOrderCount']=0;
        $data['quarter']['overOrderCount']=0;
        $data['year']['payOrderCount']=0;
        $data['year']['overOrderCount']=0;
        $quarterOrder=[];
        $overQuarterOrder=[];
        $yearOrder=[];
        $overYearOrder=[];
        foreach($orderMonthPayData as $val){
            //当月订单
            if($val['pay_time']<=$monthEnd && $val['pay_time']>=$monthBegin){
                $data['month']['payOrderCount']+=1;
                if($val['overdue_status']==1){
                    $data['month']['overOrderCount']+=1;
                }
            }
             //上月订单
            if($val['pay_time']<=$lastMonthEnd && $val['pay_time']>=$lastMonthBegin){
                $data['lastMonth']['payOrderCount']+=1;
                if($val['overdue_status']==1){
                    $data['lastMonth']['overOrderCount']+=1;
                }
            }
             //当前季度订单
            if($val['pay_time']<=$quarterEnd && $val['pay_time']>=$quarterBegin){
                if(!in_array($val['orderid'],$quarterOrder)){
                    $data['quarter']['payOrderCount']+=1;
                    $quarterOrder[]=$val['orderid'];
                }
                
                if($val['overdue_status']==1){
                    if(!in_array($val['orderid'],$overQuarterOrder)){
                        $data['quarter']['overOrderCount']+=1;
                        $overQuarterOrder[]=$val['orderid'];
                    }
                }
            }
            //当前年度订单
            if($val['pay_time']<=$yearEnd && $val['pay_time']>=$yearBegin){
                if(!in_array($val['orderid'],$yearOrder)){
                    $data['year']['payOrderCount']+=1;
                    $yearOrder[]=$val['orderid'];
                }
                if($val['overdue_status']==1){
                    if(!in_array($val['orderid'],$overYearOrder)){
                         $data['year']['overOrderCount']+=1;
                         $overYearOrder[]=$val['orderid'];
                    }
                }
            }
        }
        $this->ajaxReturn($data);
    }
    public function getCity(){
        $city=M('city');
        $cityInfos=$city->select();
        foreach($cityInfos as $val){
            if($val['type']==1){
                $provinceData[$val['id']]=$val;
            }
            if($val['type']==2){
                $cityData[$val['pid']][]=$val;   
            }
        }
        foreach($provinceData as $key=>$val){
            $provinceData[$key]['city']=$cityData[$val['id']];
        }
        $this->ajaxReturn($provinceData); 
    }
    
    public function getWayuserPass(){
        $whereCSAdmin="test_sign!=1 and position=3";
        if(I('request.province')!=0){
            //获取该省份下所以的销售顾问
            $whereCSAdmin.=" and provinceid=".I('request.province');
            
        }
        if(I('request.city')!=0){
            //获取该城市下所以的销售顾问
            $whereCSAdmin.=" and cityid=".I('request.city');
        }
        if(I('request.month')!=0){
            //月份
            $month= date("m",time());
            $year= date("Y",time());
            for($i=0;$i<=11;$i++){
                $now_year=$year;
                $now_month=$month-$i;
                if($month-$i<=0){
                    $now_year=$year-1;
                    $now_month=12+$month-$i;
                }
                $month_days=date('t', strtotime($now_year.'-'.$now_month.'-1'));
                $beginTime=strtotime($now_year.'-'.$now_month.'-1 00:00:00');
                $endTime=strtotime($now_year.'-'.$now_month.'-'.$month_days.' 23:59:59');
                if(I('request.month')-1==$i){
                    break;
                }
            }
        }else{
            $beginTime=0;
            $endTime=time();
        }
        //获取城市经理信息
        $admin=M('admin');
        $proids='';
        $pcids='';
        $ids='';
        $adminCSInfos=$admin->field('id,usernum,provinceid,cityid')->where($whereCSAdmin)->select();
        foreach($adminCSInfos as $val){
            
            $proids.=$proids?','.$val['provinceid']:$val['provinceid'];
            $pcids.=$pcids?','.$val['cityid']:$val['cityid'];
            $pcids.=$pcids?','.$val['provinceid']:$val['provinceid'];
            $ids.=$ids?','.$val['id']:$val['id'];
            $adminCSData[$val["id"]]=$val;
        }
        //获取销售顾问信息
        if($ids){
            $whereGWAdmin="test_sign!=1 and position=1 and pid in (".$ids.")";
        }else{
            $whereGWAdmin="test_sign!=1 and position=1 and pid in ('')"; 
        }
        
        $adminInfos=$admin->field('id,usernum,pid')->where($whereGWAdmin)->select();

        foreach($adminInfos as $val){
            
            $adminGWData[$val['id']]=$val;

            $adminGWPData[$val["pid"]]['GwCount']=$adminGWPData[$val["pid"]]['GwCount']?($adminGWPData[$val["pid"]]['GwCount']+1):1;
        }
        
        
        //获取省总信息
        if($proids){
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in (".$proids.")";
        }else{
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in ('')"; 
        }
        
        $adminSZInfos=$admin->field('id,provinceid,usernum')->where($whereSZAdmin)->select();
        foreach($adminSZInfos as $val){
            $adminSZData[$val['provinceid']]=$val;
        }
        //获取省份城市信息
        if($pcids){
            $whereCity="id in (".$pcids.")";
        }else{
            $whereCity="id in ('')"; 
        }
        $city=M('city');
        $cityInfos=$city->field('id,name')->where($whereCity)->select();
        foreach($cityInfos as $val){
            $cityData[$val['id']]=$val;
        }

        //获取所有的渠道信息
        $returnData=[];
        if($ids){
            $whereWayuser="admin_id in (".$ids.")";
        }else{
            $whereWayuser="admin_id in ('') and status>=2";
        }
        
        $wayuser=M('wayuser');
        $wayuserInfos=$wayuser->field('id,admin_id,status')->where($wherWayuser)->select();
        $wayuserids='';
        $wayuserData=[];
        foreach($wayuserInfos as $val){
            $wayuserids.=$wayuserids?','.$val['id']:$val['id'];
            $wayuserData[$val['id']]=$val;  
            $CSid=$adminGWData[$val['admin_id']]['pid'];
            if($val['status']>=2){
                $wayuserCSData[$CSid]['wayuserCount']=$wayuserCSData[$CSid]['wayuserCount']?$wayuserCSData[$CSid]['wayuserCount']+1:1;
            }   
            if($val['status']==2){
                $wayuserCSData[$CSid]['wayuserUseCount']=$wayuserCSData[$CSid]['wayuserUseCount']?$wayuserCSData[$CSid]['wayuserUseCount']+1:1;
            }       
        }
        //获取渠道操作表 
        $wayuserOperation=M('wayuser_operation');
        if($wayuserids){
            $whereOperation="status=2 or status=-1 and wayuserid in(".$wayuserids.")";
        }else{
            $whereOperation="status=2 or status=-1 and wayuserid in('')";
        }
        
        $wayuserOperatioInfos=$wayuserOperation->field('wayuserid,status,create_time')->where($whereOperation)->select();
        $wayuserOperatioData=[];
        foreach($wayuserOperatioInfos as $val){
            $CSid=$adminGWData[$wayuserData[$val['wayuserid']]['admin_id']]["pid"];
            if($val['status']==2){
                $wayuserOperationData[$CSid]['passCount']=$wayuserOperationData[$CSid]['passCount']?$wayuserOperationData[$CSid]['passCount']+1:1;
            }
            $wayuserOperationData[$CSid]['count']=$wayuserOperationData[$CSid]['count']?$wayuserOperationData[$CSid]['count']+1:1;
            if($val['create_time']<=$endTime && $val['create_time']>=$beginTime){
                if($val['status']==2){
                    $wayuserOperationData[$CSid]['nowPassCount']=$wayuserOperationData[$CSid]['nowPassCount']?$wayuserOperationData[$CSid]['nowPassCount']+1:1;
                }
                $wayuserOperationData[$CSid]['nowCount']=$wayuserOperationData[$CSid]['nowCount']?$wayuserOperationData[$CSid]['nowCount']+1:1;
            }
            
        }
        
        //整合数据
        foreach($adminCSInfos as $val){
            $arr=[];
            $arr['province']=$cityData[$val['provinceid']]['name'];
            $arr['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $arr['city']=$cityData[$val['cityid']]['name'];
            $arr['CSusernum']=$val['usernum'];
            $arr['GwCount']=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $arr['wayuserCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $arr['wayuserUseCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $arr['nowPassCount']=$wayuserOperationData[$val["id"]]['nowPassCount']?$wayuserOperationData[$val["id"]]['nowPassCount']:0;
            $arr['nowCount']=$wayuserOperationData[$val["id"]]['nowCount']?$wayuserOperationData[$val["id"]]['nowCount']:0;
            $arr['passCount']=$wayuserOperationData[$val["id"]]['passCount']?$wayuserOperationData[$val["id"]]['passCount']:0;
            $arr['count']=$wayuserOperationData[$val["id"]]['count']?$wayuserOperationData[$val["id"]]['count']:0;
            $returnData[]=$arr;

            $SZdata[$val['provinceid']]['province']=$cityData[$val['provinceid']]['name'];
            $SZdata[$val['provinceid']]['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $SZdata[$val['provinceid']]['city']='--';
            $SZdata[$val['provinceid']]['CSusernum']='--';
            $SZdata[$val['provinceid']]['GwCount']+=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $SZdata[$val['provinceid']]['wayuserCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $SZdata[$val['provinceid']]['wayuserUseCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $SZdata[$val['provinceid']]['nowPassCount']+=$wayuserOperationData[$val["id"]]['nowPassCount']?$wayuserOperationData[$val["id"]]['nowPassCount']:0;
            $SZdata[$val['provinceid']]['nowCount']+=$wayuserOperationData[$val["id"]]['nowCount']?$wayuserOperationData[$val["id"]]['nowCount']:0;
            $SZdata[$val['provinceid']]['passCount']+=$wayuserOperationData[$val["id"]]['passCount']?$wayuserOperationData[$val["id"]]['passCount']:0;
            $SZdata[$val['provinceid']]['count']+=$wayuserOperationData[$val["id"]]['count']?$wayuserOperationData[$val["id"]]['count']:0;
        }
        if(I('request.city')!=0){
            $this->ajaxReturn(array('content'=>$returnData)); 
        }else{
            $this->ajaxReturn(array('content'=>$SZdata)); 
        }
        

    }

    public function getWayuserOrderPass(){
        $whereCSAdmin="test_sign!=1 and position=3";
        if(I('request.province')!=0){
            //获取该省份下所以的销售顾问
            $whereCSAdmin.=" and provinceid=".I('request.province');
            
        }
        if(I('request.city')!=0){
            //获取该城市下所以的销售顾问
            $whereCSAdmin.=" and cityid=".I('request.city');
        }
        if(I('request.month')!=0){
            //月份
            $month= date("m",time());
            $year= date("Y",time());
            for($i=0;$i<=11;$i++){
                $now_year=$year;
                $now_month=$month-$i;
                if($month-$i<=0){
                    $now_year=$year-1;
                    $now_month=12+$month-$i;
                }
                $month_days=date('t', strtotime($now_year.'-'.$now_month.'-1'));
                $beginTime=strtotime($now_year.'-'.$now_month.'-1 00:00:00');
                $endTime=strtotime($now_year.'-'.$now_month.'-'.$month_days.' 23:59:59');
                if(I('request.month')-1==$i){
                    break;
                }
            }
        }else{
            $beginTime=0;
            $endTime=time();
        }
        //获取城市经理信息
        $admin=M('admin');
        $proids='';
        $pcids='';
        $ids='';
        $adminCSInfos=$admin->field('id,usernum,provinceid,cityid')->where($whereCSAdmin)->select();
        foreach($adminCSInfos as $val){
            
            $proids.=$proids?','.$val['provinceid']:$val['provinceid'];
            $pcids.=$pcids?','.$val['cityid']:$val['cityid'];
            $pcids.=$pcids?','.$val['provinceid']:$val['provinceid'];
            $ids.=$ids?','.$val['id']:$val['id'];
            $adminCSData[$val["id"]]=$val;
        }
        //获取销售顾问信息
        if($ids){
            $whereGWAdmin="test_sign!=1 and position=1 and pid in (".$ids.")";
        }else{
            $whereGWAdmin="test_sign!=1 and position=1 and pid in ('')"; 
        }
        
        $adminInfos=$admin->field('id,usernum,pid')->where($whereGWAdmin)->select();

        foreach($adminInfos as $val){
            
            $adminGWData[$val['id']]=$val;

            $adminGWPData[$val["pid"]]['GwCount']=$adminGWPData[$val["pid"]]['GwCount']?($adminGWPData[$val["pid"]]['GwCount']+1):1;
        }
        
        
        //获取省总信息
        if($proids){
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in (".$proids.")";
        }else{
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in ('')"; 
        }
        
        $adminSZInfos=$admin->field('id,provinceid,usernum')->where($whereSZAdmin)->select();
        foreach($adminSZInfos as $val){
            $adminSZData[$val['provinceid']]=$val;
        }
        //获取省份城市信息
        if($pcids){
            $whereCity="id in (".$pcids.")";
        }else{
            $whereCity="id in ('')"; 
        }
        $city=M('city');
        $cityInfos=$city->field('id,name')->where($whereCity)->select();
        foreach($cityInfos as $val){
            $cityData[$val['id']]=$val;
        }

        //获取所有的渠道信息
        $returnData=[];
        if($ids){
            $whereWayuser="admin_id in (".$ids.") and status>=2";
        }else{
            $whereWayuser="admin_id in ('') and status>=2"; 
        }
        
        $wayuser=M('wayuser');
        $wayuserInfos=$wayuser->field('id,admin_id,waynum,status')->where($wherWayuser)->select();
        $waynums='';
        $wayuserData=[];
        foreach($wayuserInfos as $val){
            $waynums.=$waynums?','.$val['waynum']:$val['waynum'];
            $wayuserData[$val['waynum']]=$val;  
            $CSid=$adminGWData[$val['admin_id']]['pid'];
            if($val['status']>=2){
                $wayuserCSData[$CSid]['wayuserCount']=$wayuserCSData[$CSid]['wayuserCount']?$wayuserCSData[$CSid]['wayuserCount']+1:1;
            }   
            if($val['status']==2){
                $wayuserCSData[$CSid]['wayuserUseCount']=$wayuserCSData[$CSid]['wayuserUseCount']?$wayuserCSData[$CSid]['wayuserUseCount']+1:1;
            }       
        }
        //获取用户
        $user=M('user');
        if($waynums){
            $whereUser="waynum in (".$waynums.")";
        }else{
            $whereUser="waynum in ('') and waynum is not null";
        }
        $userInfos=$user->field('id,waynum')->where($whereUser)->select();
        $userData=[];
        
        foreach($userInfos as $val){
            $uids.=$uids?','.$val['id']:$val['id'];
            $userData[$val['id']]=$val;
            
        }
        
        //获取订单
        $order=M('order');
        if($uids){
            $whereOrder="uid in (".$uids.")";
        }else{
            $whereOrder="uid in ('')";
        }
        $orderInfos=$order->field('uid,orderid')->where($whereOrder)->select();
        $orderData=[];
        foreach($orderInfos as $val){
            $orderids.=$orderids?','.$val['orderid']:$val['orderid'];
            $orderData[$val['orderid']]=$val;
            
        }
        //获取订单操作表
        if($orderids){
            $whereOperation="(status=2 or status=-1) and orderid in (".$orderids.")";
        }else{
            $whereOperation="(status=2 or status=-1) and orderid in ('')";
        }
        $orderOperation=M('order_operation');
        $orderOperationInfos=$orderOperation->field('orderid,status,create_time')->where($whereOperation)->select();

        foreach($orderOperationInfos as $val){
            $CSid=$adminGWData[$wayuserData[$userData[$orderData[$val['orderid']]['uid']]['waynum']]['admin_id']]["pid"];
            if($val['status']==2){
                $orderOperationData[$CSid]['passCount']=$orderOperationData[$CSid]['passCount']?$orderOperationData[$CSid]['passCount']+1:1;
            }
            $orderOperationData[$CSid]['count']=$orderOperationData[$CSid]['count']?$orderOperationData[$CSid]['count']+1:1;
            if($val['create_time']<=$endTime && $val['create_time']>=$beginTime){
                if($val['status']==2){
                    $orderOperationData[$CSid]['nowPassCount']=$orderOperationData[$CSid]['nowPassCount']?$orderOperationData[$CSid]['nowPassCount']+1:1;
                }
                $orderOperationData[$CSid]['nowCount']=$orderOperationData[$CSid]['nowCount']?$orderOperationData[$CSid]['nowCount']+1:1;
            }
            
        }
        //整合数据
        foreach($adminCSInfos as $val){
            $arr=[];
            $arr['province']=$cityData[$val['provinceid']]['name'];
            $arr['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $arr['city']=$cityData[$val['cityid']]['name'];
            $arr['CSusernum']=$val['usernum'];
            $arr['GwCount']=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $arr['wayuserCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $arr['wayuserUseCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $arr['nowPassCount']=$orderOperationData[$val["id"]]['nowPassCount']?$orderOperationData[$val["id"]]['nowPassCount']:0;
            $arr['nowCount']=$orderOperationData[$val["id"]]['nowCount']?$orderOperationData[$val["id"]]['nowCount']:0;
            $arr['passCount']=$orderOperationData[$val["id"]]['passCount']?$orderOperationData[$val["id"]]['passCount']:0;
            $arr['count']=$orderOperationData[$val["id"]]['count']?$orderOperationData[$val["id"]]['count']:0;
            $returnData[]=$arr;

            $SZdata[$val['provinceid']]['province']=$cityData[$val['provinceid']]['name'];
            $SZdata[$val['provinceid']]['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $SZdata[$val['provinceid']]['city']='--';
            $SZdata[$val['provinceid']]['CSusernum']='--';
            $SZdata[$val['provinceid']]['GwCount']+=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $SZdata[$val['provinceid']]['wayuserCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $SZdata[$val['provinceid']]['wayuserUseCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $SZdata[$val['provinceid']]['nowPassCount']+=$orderOperationData[$val["id"]]['nowPassCount']?$orderOperationData[$val["id"]]['nowPassCount']:0;
            $SZdata[$val['provinceid']]['nowCount']+=$orderOperationData[$val["id"]]['nowCount']?$orderOperationData[$val["id"]]['nowCount']:0;
            $SZdata[$val['provinceid']]['passCount']+=$orderOperationData[$val["id"]]['passCount']?$orderOperationData[$val["id"]]['passCount']:0;
            $SZdata[$val['provinceid']]['count']+=$orderOperationData[$val["id"]]['count']?$orderOperationData[$val["id"]]['count']:0;
        }
        if(I('request.city')!=0){
            $this->ajaxReturn(array('content'=>$returnData)); 
        }else{
            $this->ajaxReturn(array('content'=>$SZdata)); 
        } 

    }
    public function getWayuserOrderOver(){
        $whereCSAdmin="test_sign!=1 and position=3";
        if(I('request.province')!=0){
            //获取该省份下所以的销售顾问
            $whereCSAdmin.=" and provinceid=".I('request.province');
            
        }
        if(I('request.city')!=0){
            //获取该城市下所以的销售顾问
            $whereCSAdmin.=" and cityid=".I('request.city');
        }
        if(I('request.month')!=0){
            //月份
            $month= date("m",time());
            $year= date("Y",time());
            for($i=0;$i<=11;$i++){
                $now_year=$year;
                $now_month=$month-$i;
                if($month-$i<=0){
                    $now_year=$year-1;
                    $now_month=12+$month-$i;
                }
                $month_days=date('t', strtotime($now_year.'-'.$now_month.'-1'));
                $beginTime=strtotime($now_year.'-'.$now_month.'-1 00:00:00');
                $endTime=strtotime($now_year.'-'.$now_month.'-'.$month_days.' 23:59:59');
                if(I('request.month')-1==$i){
                    break;
                }
            }
        }else{
            $beginTime=0;
            $endTime=time();
        }
        //获取城市经理信息
        $admin=M('admin');
        $proids='';
        $pcids='';
        $ids='';
        $adminCSInfos=$admin->field('id,usernum,provinceid,cityid')->where($whereCSAdmin)->select();
        foreach($adminCSInfos as $val){
            
            $proids.=$proids?','.$val['provinceid']:$val['provinceid'];
            $pcids.=$pcids?','.$val['cityid']:$val['cityid'];
            $pcids.=$pcids?','.$val['provinceid']:$val['provinceid'];
            $ids.=$ids?','.$val['id']:$val['id'];
            $adminCSData[$val["id"]]=$val;
        }
        //获取销售顾问信息
        if($ids){
            $whereGWAdmin="test_sign!=1 and position=1 and pid in (".$ids.")";
        }else{
            $whereGWAdmin="test_sign!=1 and position=1 and pid in ('')"; 
        }
        
        $adminInfos=$admin->field('id,usernum,pid')->where($whereGWAdmin)->select();

        foreach($adminInfos as $val){
            $Gwids.=$Gwids?','.$val['id']:$val['id'];
            $adminGWData[$val['id']]=$val;

            $adminGWPData[$val["pid"]]['GwCount']=$adminGWPData[$val["pid"]]['GwCount']?($adminGWPData[$val["pid"]]['GwCount']+1):1;
        }
        
        //获取省总信息
        if($proids){
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in (".$proids.")";
        }else{
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in ('')"; 
        }
        
        $adminSZInfos=$admin->field('id,provinceid,usernum')->where($whereSZAdmin)->select();
        foreach($adminSZInfos as $val){
            $adminSZData[$val['provinceid']]=$val;
        }
        //获取省份城市信息
        if($pcids){
            $whereCity="id in (".$pcids.")";
        }else{
            $whereCity="id in ('')"; 
        }
        $city=M('city');
        $cityInfos=$city->field('id,name')->where($whereCity)->select();
        foreach($cityInfos as $val){
            $cityData[$val['id']]=$val;
        }

        //获取所有的渠道信息
        $returnData=[];
        if($Gwids){
            $whereWayuser="admin_id in (".$Gwids.") and status>=2";
        }else{
            $whereWayuser="admin_id in ('') and status>=2";
        }
        $wayuser=M('wayuser');
        $wayuserInfos=$wayuser->field('id,admin_id,waynum,status')->where($whereWayuser)->select();
        $waynums='';
        $wayuserData=[];
        foreach($wayuserInfos as $val){
            $waynums.=$waynums?','.$val['waynum']:$val['waynum'];
            $wayuserData[$val['waynum']]=$val;  
            $CSid=$adminGWData[$val['admin_id']]['pid'];
            if($val['status']>=2){
                $wayuserCSData[$CSid]['wayuserCount']=$wayuserCSData[$CSid]['wayuserCount']?$wayuserCSData[$CSid]['wayuserCount']+1:1;
            }   
            if($val['status']==2){
                $wayuserCSData[$CSid]['wayuserUseCount']=$wayuserCSData[$CSid]['wayuserUseCount']?$wayuserCSData[$CSid]['wayuserUseCount']+1:1;
            }       
        }
        //获取用户
        $user=M('user');
        if($waynums){
            $whereUser="waynum in (".$waynums.")";
        }else{
            $whereUser="waynum in ('') and waynum is not null";
        }
        $userInfos=$user->field('id,waynum')->where($whereUser)->select();
        $userData=[];
        
        foreach($userInfos as $val){
            $uids.=$uids?','.$val['id']:$val['id'];
            $userData[$val['id']]=$val;
            
        }
        
        //获取订单
        $order=M('order');
        if($uids){
            $whereOrder="uid in (".$uids.")";
        }else{
            $whereOrder="uid in ('')";
        }
        $orderInfos=$order->field('uid,orderid')->where($whereOrder)->select();
        $orderData=[];
        foreach($orderInfos as $val){
            $orderids.=$orderids?','.$val['orderid']:$val['orderid'];
            $orderData[$val['orderid']]=$val;
            
        }
        //获取订单还款信息
        if($orderids){
            $whereMonthPay="orderid in (".$orderids.")and pay_time<=".time();
        }else{
            $whereMonthPay="orderid in ('') and pay_time<=".time();
        }
        $orderMonthPay=M('order_month_pay');
        $orderMonthPayinfos=$orderMonthPay->field('orderid,overdue_status,pay_time')->where($whereMonthPay)->select();

        foreach($orderMonthPayinfos as $val){
            if($val['overdue_status']==1){
                if(!in_array($val['orderid'],$overCountArr)){
                    $orderMonthPayData[$CSid]['overCount']=$orderMonthPayData[$CSid]['overCount']?$orderMonthPayData[$CSid]['overCount']+1:1;
                    $overCountArr[]=$val['orderid'];
                }
            }
            if(!in_array($val['orderid'],$countArr)){
                $orderMonthPayData[$CSid]['count']=$orderMonthPayData[$CSid]['count']?$orderMonthPayData[$CSid]['count']+1:1;
                $countArr[]=$val['orderid'];
            }
            if($val['pay_time']<=$endTime && $val['pay_time']>=$beginTime){
                if($val['overdue_status']==1){
                    if(!in_array($val['orderid'],$nowOverCountArr)){
                        $orderMonthPayData[$CSid]['nowOverCount']=$orderMonthPayData[$CSid]['nowOverCount']?$orderMonthPayData[$CSid]['nowOverCount']+1:1;
                        $nowOverCountArr[]=$val['orderid'];
                    }
                }
                if(!in_array($val['orderid'],$nowCountArr)){
                    $orderMonthPayData[$CSid]['nowCount']=$orderMonthPayData[$CSid]['nowCount']?$orderMonthPayData[$CSid]['nowCount']+1:1;
                    $nowCountArr[]=$val['orderid'];
                }
            }
            
        }
        //整合数据
        foreach($adminCSInfos as $val){
            $arr=[];
            $arr['province']=$cityData[$val['provinceid']]['name'];
            $arr['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $arr['city']=$cityData[$val['cityid']]['name'];
            $arr['CSusernum']=$val['usernum'];
            $arr['GwCount']=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $arr['wayuserCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $arr['wayuserUseCount']=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $arr['nowOverCount']=$orderMonthPayData[$val["id"]]['nowOverCount']?$orderMonthPayData[$val["id"]]['nowOverCount']:0;
            $arr['nowCount']=$orderMonthPayData[$val["id"]]['nowCount']?$orderMonthPayData[$val["id"]]['nowCount']:0;
            $arr['overCount']=$orderMonthPayData[$val["id"]]['overCount']?$orderMonthPayData[$val["id"]]['overCount']:0;
            $arr['count']=$orderMonthPayData[$val["id"]]['count']?$orderMonthPayData[$val["id"]]['count']:0;
            $returnData[]=$arr;

            $SZdata[$val['provinceid']]['province']=$cityData[$val['provinceid']]['name'];
            $SZdata[$val['provinceid']]['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $SZdata[$val['provinceid']]['city']='--';
            $SZdata[$val['provinceid']]['CSusernum']='--';
            $SZdata[$val['provinceid']]['GwCount']+=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;
            $SZdata[$val['provinceid']]['wayuserCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;
            $SZdata[$val['provinceid']]['wayuserUseCount']+=$wayuserCSData[$val["id"]]['wayuserCount']?$wayuserCSData[$val["id"]]['wayuserCount']:0;

            $SZdata[$val['provinceid']]['nowOverCount']+=$orderMonthPayData[$val["id"]]['nowOverCount']?$orderMonthPayData[$val["id"]]['nowOverCount']:0;
            $SZdata[$val['provinceid']]['nowCount']+=$orderMonthPayData[$val["id"]]['nowCount']?$orderMonthPayData[$val["id"]]['nowCount']:0;
            $SZdata[$val['provinceid']]['overCount']+=$orderMonthPayData[$val["id"]]['overCount']?$orderMonthPayData[$val["id"]]['overCount']:0;
            $SZdata[$val['provinceid']]['count']+=$orderMonthPayData[$val["id"]]['count']?$orderMonthPayData[$val["id"]]['count']:0;
        }
        if(I('request.city')!=0){
            $this->ajaxReturn(array('content'=>$returnData)); 
        }else{
            $this->ajaxReturn(array('content'=>$SZdata)); 
        } 

    }

    public function getOrderPass(){
        $whereCSAdmin="test_sign!=1 and position=3";
        if(I('request.province')!=0){
            //获取该省份下所以的销售顾问
            $whereCSAdmin.=" and provinceid=".I('request.province');
            
        }
        if(I('request.city')!=0){
            //获取该城市下所以的销售顾问
            $whereCSAdmin.=" and cityid=".I('request.city');
        }
        if(I('request.month')!=0){
            //月份
            $month= date("m",time());
            $year= date("Y",time());
            for($i=0;$i<=11;$i++){
                $now_year=$year;
                $now_month=$month-$i;
                if($month-$i<=0){
                    $now_year=$year-1;
                    $now_month=12+$month-$i;
                }
                $month_days=date('t', strtotime($now_year.'-'.$now_month.'-1'));
                $beginTime=strtotime($now_year.'-'.$now_month.'-1 00:00:00');
                $endTime=strtotime($now_year.'-'.$now_month.'-'.$month_days.' 23:59:59');
                if(I('request.month')-1==$i){
                    break;
                }
            }
        }else{
            $beginTime=0;
            $endTime=time();
        }
        //获取城市经理信息
        $admin=M('admin');
        $proids='';
        $pcids='';
        $ids='';
        $adminCSInfos=$admin->field('id,usernum,provinceid,cityid')->where($whereCSAdmin)->select();
        foreach($adminCSInfos as $val){
            
            $proids.=$proids?','.$val['provinceid']:$val['provinceid'];
            $pcids.=$pcids?','.$val['cityid']:$val['cityid'];
            $pcids.=$pcids?','.$val['provinceid']:$val['provinceid'];
            $ids.=$ids?','.$val['id']:$val['id'];
            $adminCSData[$val["id"]]=$val;
        }
        //获取销售顾问信息
        if($ids){
            $whereGWAdmin="test_sign!=1 and position=1 and pid in (".$ids.")";
        }else{
            $whereGWAdmin="test_sign!=1 and position=1 and pid in ('')"; 
        }
        
        $adminInfos=$admin->field('id,usernum,pid')->where($whereGWAdmin)->select();

        foreach($adminInfos as $val){
            $usernums.=$usernums?",'".$val['usernum']."'":"'".$val['usernum']."'";
            $adminGWData[$val['usernum']]=$val;

            $adminGWPData[$val["pid"]]['GwCount']=$adminGWPData[$val["pid"]]['GwCount']?($adminGWPData[$val["pid"]]['GwCount']+1):1;
        }
        
        
        //获取省总信息
        if($proids){
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in (".$proids.")";
        }else{
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in ('')"; 
        }
        
        $adminSZInfos=$admin->field('id,provinceid,usernum')->where($whereSZAdmin)->select();
        foreach($adminSZInfos as $val){
            $adminSZData[$val['provinceid']]=$val;
        }
        //获取省份城市信息
        if($pcids){
            $whereCity="id in (".$pcids.")";
        }else{
            $whereCity="id in ('')"; 
        }
        $city=M('city');
        $cityInfos=$city->field('id,name')->where($whereCity)->select();
        foreach($cityInfos as $val){
            $cityData[$val['id']]=$val;
        }

        //获取订单操作表（）
        if($usernums){
            $whereOperation="status=0 and usernum in (".$usernums.")";
        }else{
            $whereOperation="status=0 and usernum in ('')";
        }
        $orderOperation=M('order_operation');
        $orderOperInfos=$orderOperation->field('orderid,usernum')->where($whereOperation)->select();
        
        foreach($orderOperInfos as $val){
            $orderids.=$orderids?','.$val['orderid']:$val['orderid'];
            $orderOperData[$val['orderid']]=$val;
            
        }

        //获取订单操作表
        if($orderids){
            $whereOperation="(status=2 or status=-1) and orderid in (".$orderids.")";
        }else{
            $whereOperation="(status=2 or status=-1) and orderid in ('')";
        }
        $orderOperation=M('order_operation');
        $orderOperationInfos=$orderOperation->field('orderid,status,create_time')->where($whereOperation)->select();

        foreach($orderOperationInfos as $val){
            $CSid=$adminGWData[$orderOperData[$val['orderid']]['usernum']]['pid'];
            if($val['status']==2){
                $orderOperationData[$CSid]['passCount']=$orderOperationData[$CSid]['passCount']?$orderOperationData[$CSid]['passCount']+1:1;
            }
            $orderOperationData[$CSid]['count']=$orderOperationData[$CSid]['count']?$orderOperationData[$CSid]['count']+1:1;
            if($val['create_time']<=$endTime && $val['create_time']>=$beginTime){
                if($val['status']==2){
                    $orderOperationData[$CSid]['nowPassCount']=$orderOperationData[$CSid]['nowPassCount']?$orderOperationData[$CSid]['nowPassCount']+1:1;
                }
                $orderOperationData[$CSid]['nowCount']=$orderOperationData[$CSid]['nowCount']?$orderOperationData[$CSid]['nowCount']+1:1;
            }
            
        }
        //整合数据
        foreach($adminCSInfos as $val){
            $arr=[];
            $arr['province']=$cityData[$val['provinceid']]['name'];
            $arr['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $arr['city']=$cityData[$val['cityid']]['name'];
            $arr['CSusernum']=$val['usernum'];
            $arr['GwCount']=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;

            $arr['nowPassCount']=$orderOperationData[$val["id"]]['nowPassCount']?$orderOperationData[$val["id"]]['nowPassCount']:0;
            $arr['nowCount']=$orderOperationData[$val["id"]]['nowCount']?$orderOperationData[$val["id"]]['nowCount']:0;
            $arr['passCount']=$orderOperationData[$val["id"]]['passCount']?$orderOperationData[$val["id"]]['passCount']:0;
            $arr['count']=$orderOperationData[$val["id"]]['count']?$orderOperationData[$val["id"]]['count']:0;
            $returnData[]=$arr;

            $SZdata[$val['provinceid']]['province']=$cityData[$val['provinceid']]['name'];
            $SZdata[$val['provinceid']]['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $SZdata[$val['provinceid']]['city']='--';
            $SZdata[$val['provinceid']]['CSusernum']='--';
            $SZdata[$val['provinceid']]['GwCount']+=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;

            $SZdata[$val['provinceid']]['nowPassCount']+=$orderOperationData[$val["id"]]['nowPassCount']?$orderOperationData[$val["id"]]['nowPassCount']:0;
            $SZdata[$val['provinceid']]['nowCount']+=$orderOperationData[$val["id"]]['nowCount']?$orderOperationData[$val["id"]]['nowCount']:0;
            $SZdata[$val['provinceid']]['passCount']+=$orderOperationData[$val["id"]]['passCount']?$orderOperationData[$val["id"]]['passCount']:0;
            $SZdata[$val['provinceid']]['count']+=$orderOperationData[$val["id"]]['count']?$orderOperationData[$val["id"]]['count']:0;
        }
        if(I('request.city')!=0){
            $this->ajaxReturn(array('content'=>$returnData)); 
        }else{
            $this->ajaxReturn(array('content'=>$SZdata)); 
        } 

    }
    public function getOrderOver(){
        $whereCSAdmin="test_sign!=1 and position=3";
        if(I('request.province')!=0){
            //获取该省份下所以的销售顾问
            $whereCSAdmin.=" and provinceid=".I('request.province');
            
        }
        if(I('request.city')!=0){
            //获取该城市下所以的销售顾问
            $whereCSAdmin.=" and cityid=".I('request.city');
        }
        if(I('request.month')!=0){
            //月份
            $month= date("m",time());
            $year= date("Y",time());
            for($i=0;$i<=11;$i++){
                $now_year=$year;
                $now_month=$month-$i;
                if($month-$i<=0){
                    $now_year=$year-1;
                    $now_month=12+$month-$i;
                }
                $month_days=date('t', strtotime($now_year.'-'.$now_month.'-1'));
                $beginTime=strtotime($now_year.'-'.$now_month.'-1 00:00:00');
                $endTime=strtotime($now_year.'-'.$now_month.'-'.$month_days.' 23:59:59');
                if(I('request.month')-1==$i){
                    break;
                }
            }
        }else{
            $beginTime=0;
            $endTime=time();
        }
        //获取城市经理信息
        $admin=M('admin');
        $proids='';
        $pcids='';
        $ids='';
        $adminCSInfos=$admin->field('id,usernum,provinceid,cityid')->where($whereCSAdmin)->select();
        foreach($adminCSInfos as $val){
            
            $proids.=$proids?','.$val['provinceid']:$val['provinceid'];
            $pcids.=$pcids?','.$val['cityid']:$val['cityid'];
            $pcids.=$pcids?','.$val['provinceid']:$val['provinceid'];
            $ids.=$ids?','.$val['id']:$val['id'];
            $adminCSData[$val["id"]]=$val;
        }
        //获取销售顾问信息
        if($ids){
            $whereGWAdmin="test_sign!=1 and position=1 and pid in (".$ids.")";
        }else{
            $whereGWAdmin="test_sign!=1 and position=1 and pid in ('')"; 
        }
        
        $adminInfos=$admin->field('id,usernum,pid')->where($whereGWAdmin)->select();

        foreach($adminInfos as $val){
            $usernums.=$usernums?",'".$val['usernum']."'":"'".$val['usernum']."'";
            $adminGWData[$val['usernum']]=$val;

            $adminGWPData[$val["pid"]]['GwCount']=$adminGWPData[$val["pid"]]['GwCount']?($adminGWPData[$val["pid"]]['GwCount']+1):1;
        }
        
        
        //获取省总信息
        if($proids){
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in (".$proids.")";
        }else{
            $whereSZAdmin="test_sign!=1 and position=4 and provinceid in ('')"; 
        }
        
        $adminSZInfos=$admin->field('id,provinceid,usernum')->where($whereSZAdmin)->select();
        foreach($adminSZInfos as $val){
            $adminSZData[$val['provinceid']]=$val;
        }
        //获取省份城市信息
        if($pcids){
            $whereCity="id in (".$pcids.")";
        }else{
            $whereCity="id in ('')"; 
        }
        $city=M('city');
        $cityInfos=$city->field('id,name')->where($whereCity)->select();
        foreach($cityInfos as $val){
            $cityData[$val['id']]=$val;
        }

       
        //获取订单操作表（）
        if($usernums){
            $whereOperation="status=0 and usernum in (".$usernums.")";
        }else{
            $whereOperation="status=0 and usernum in ('')";
        }
        $orderOperation=M('order_operation');
        $orderOperInfos=$orderOperation->field('orderid,usernum')->where($whereOperation)->select();
        foreach($orderOperInfos as $val){
            $orderids.=$orderids?','.$val['orderid']:$val['orderid'];
            $orderOperData[$val['orderid']]=$val;
            
        }
        
        //获取订单还款信息
        if($orderids){
            $whereMonthPay="orderid in (".$orderids.")and pay_time<=".time();
        }else{
            $whereMonthPay="orderid in ('') and pay_time<=".time();
        }
        $orderMonthPay=M('order_month_pay');
        $orderMonthPayinfos=$orderMonthPay->field('orderid,overdue_status,pay_time')->where($whereMonthPay)->select();
        foreach($orderMonthPayinfos as $val){
            $CSid=$adminGWData[$orderOperData[$val['orderid']]['usernum']]['pid'];

            if($val['overdue_status']==1){
                if(!in_array($val['orderid'],$overCountArr)){
                    $orderMonthPayData[$CSid]['overCount']=$orderMonthPayData[$CSid]['overCount']?$orderMonthPayData[$CSid]['overCount']+1:1;
                    $overCountArr[]=$val['orderid'];
                }
            }
            if(!in_array($val['orderid'],$countArr)){
                $orderMonthPayData[$CSid]['count']=$orderMonthPayData[$CSid]['count']?$orderMonthPayData[$CSid]['count']+1:1;
                $countArr[]=$val['orderid'];
            }
            if($val['pay_time']<=$endTime && $val['pay_time']>=$beginTime){
                if($val['overdue_status']==1){
                    if(!in_array($val['orderid'],$nowOverCountArr)){
                        $orderMonthPayData[$CSid]['nowOverCount']=$orderMonthPayData[$CSid]['nowOverCount']?$orderMonthPayData[$CSid]['nowOverCount']+1:1;
                        $nowOverCountArr[]=$val['orderid'];
                    }
                }
                if(!in_array($val['orderid'],$nowCountArr)){
                    $orderMonthPayData[$CSid]['nowCount']=$orderMonthPayData[$CSid]['nowCount']?$orderMonthPayData[$CSid]['nowCount']+1:1;
                    $nowCountArr[]=$val['orderid'];
                }
            }
            
        }
        //整合数据
        foreach($adminCSInfos as $val){
            $arr=[];
            $arr['province']=$cityData[$val['provinceid']]['name'];
            $arr['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $arr['city']=$cityData[$val['cityid']]['name'];
            $arr['CSusernum']=$val['usernum'];
            $arr['GwCount']=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;

            $arr['nowOverCount']=$orderMonthPayData[$val["id"]]['nowOverCount']?$orderMonthPayData[$val["id"]]['nowOverCount']:0;
            $arr['nowCount']=$orderMonthPayData[$val["id"]]['nowCount']?$orderMonthPayData[$val["id"]]['nowCount']:0;
            $arr['overCount']=$orderMonthPayData[$val["id"]]['overCount']?$orderMonthPayData[$val["id"]]['overCount']:0;
            $arr['count']=$orderMonthPayData[$val["id"]]['count']?$orderMonthPayData[$val["id"]]['count']:0;
            $returnData[]=$arr;

            $SZdata[$val['provinceid']]['province']=$cityData[$val['provinceid']]['name'];
            $SZdata[$val['provinceid']]['SZusernum']=$adminSZData[$val['provinceid']]['usernum'];
            $SZdata[$val['provinceid']]['city']='--';
            $SZdata[$val['provinceid']]['CSusernum']='--';
            $SZdata[$val['provinceid']]['GwCount']+=$adminGWPData[$val["id"]]['GwCount']?$adminGWPData[$val["id"]]['GwCount']:0;

            $SZdata[$val['provinceid']]['nowOverCount']+=$orderMonthPayData[$val["id"]]['nowOverCount']?$orderMonthPayData[$val["id"]]['nowOverCount']:0;
            $SZdata[$val['provinceid']]['nowCount']+=$orderMonthPayData[$val["id"]]['nowCount']?$orderMonthPayData[$val["id"]]['nowCount']:0;
            $SZdata[$val['provinceid']]['overCount']+=$orderMonthPayData[$val["id"]]['overCount']?$orderMonthPayData[$val["id"]]['overCount']:0;
            $SZdata[$val['provinceid']]['count']+=$orderMonthPayData[$val["id"]]['count']?$orderMonthPayData[$val["id"]]['count']:0;
        }
        if(I('request.city')!=0){
            $this->ajaxReturn(array('content'=>$returnData)); 
        }else{
            $this->ajaxReturn(array('content'=>$SZdata)); 
        }  

    }
     
}